<?php

namespace App\Kuafu\Sms\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Base\Model\Traits\KfSoftDeletes;

class SmsCodeRecordModel extends BaseModel
{

    use KfSoftDeletes;

    public $timestamps = false;

    protected $connection = 'mysql';
    protected $table      = 'sms_code_record';

    protected $fillable = ['mobile', 'code', 'smsClient', 'createdAt', 'expiredAt', 'isDeleted','type'];

    /**
     * 添加记录
     *
     * @param $data
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model
     */
    public static function addRecord($data)
    {
        $data += [
            'createdAt' => time(),
            'expiredAt' => time() + 10 * 60
        ];
        return self::query()->create($data);
    }
}
